<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in dataList" :key="item.img_url">
                <router-link :to="'/home/singleNews/'+ item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <span class="title">{{ item.title }}</span>
                        <p class='mui-ellipsis'>
                            <span >发表时间：{{ item.add_time | dateFormat }}</span> <span >点击次数：{{ item.click }}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
    import { Toast } from "mint-ui";

    export default {
        data(){
            return {
                dataList:[]
            }
        },
        created(){
            this.getAllNews();
        },
        methods:{
            getAllNews(){
                 this.$http.get("api/getnewslist").then(result=>{
                    result = result.body;
                    if(result.status  === 0){ //调用成功
                        this.dataList = result.message;
                    }else{
                        Toast("获取新闻列表数据失败！");
                    }
                })
            }
        }
    }
</script>

<style scoped>
    .title{
        font-size: 15px;
        font-weight: bold;
    }

    .mui-ellipsis{
        font-size:13px;
        color: #797979;
        display: flex;
        justify-content: space-between;
    }


</style>